package com.icebergteam.warfacewidget.ui;

import com.icebergteam.warfacewidget.R;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

public class ProgressDialogView {
	LinearLayout	mainView;
	ProgressBar		progressIndicator;
	
	public ProgressDialogView(FrameLayout layout, LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		this.mainView = (LinearLayout) inflater.inflate(R.layout.progress_dialog_layout, container, false);
		progressIndicator = (ProgressBar) mainView.findViewById(R.id.progress_indicator);
		layout.addView(mainView);
	}
	
	public void show() {
		mainView.setVisibility(View.VISIBLE);
	}
	
	public void hide() {
		mainView.setVisibility(View.GONE);
	}
	
	public void setProgress(int progress) {
		if(progress != -1)
			progressIndicator.setIndeterminate(false);
		else
			progressIndicator.setIndeterminate(true);
		
		progressIndicator.setProgress(progress);
	}
	
	public LinearLayout getView() {
		return mainView;
	}
}
